package background;

import util.AnimationHelper;
import database.FTodoEntities;
import entity.DummyFinishTask;
import entity.FTodo;
import android.os.AsyncTask;
import android.view.View;

public class FinishTaskAsyn extends AsyncTask<DummyFinishTask, Integer, DummyFinishTask> {
		
	@Override
	protected DummyFinishTask doInBackground(DummyFinishTask... dummys) {
		
		DummyFinishTask dummy = dummys[0];
		FTodo ftodo = dummy.ftodo;
		ftodo.isFinish = 1;
		
		boolean result = FTodoEntities.getInstance(dummy.context).updateFTodo(ftodo);
		if(result)
			return dummy;	
		return null;
	}
	
	@Override
	protected void onPostExecute(DummyFinishTask result) {
		
		if(result != null){
			result.cbFinish.setEnabled(false);
			result.txtFinish.setVisibility(View.VISIBLE);
			AnimationHelper.animFinishTask(result.txtFinish);
			result.progressBar.setVisibility(View.GONE);
			result.btnDeleteTask.setVisibility(View.VISIBLE);
		}
	}

}
